//常用函数库
function getQueryVariable(variable)
{
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if(pair[0] == variable){return pair[1];}
    }
    return(false);
}
 function request(url,data,method="post"){
    return new Promise(function (resolve,reject) {
        $.ajax({
            url:url,
            data:data,
            // async:false,
            type:method,
            dataType:'json',
            headers:{
                'token':localStorage.getItem('hypercmfname')+'_'+localStorage.getItem('token'),
                'accept':'*/*'
            },
            success:function(res){
                console.log('resolve',res)
                resolve(res)
            },error:function(res){
                console.log('reject',res)
                reject(res)
            }
        })

    })

}
//1、获取时间戳对应的时间，格式YYYY-MM-DD
function timstampFormatDate(timeStamp,format) {
    var date = new Date(timeStamp);
    //console.log(date); 结果为：Tue Apr 02 2019 07:49:23 GMT+0800 (中国标准时间)
    var seperator = ":";
    var seperator1 = "-";
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate();
    var hour = date.getHours()<10?"0"+date.getHours():date.getHours()
    var minutes=date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes()
    var seconds=date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds()
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    if(format=="datetime"){
        var currentdate = year + seperator1 + month + seperator1 + strDate +" "+hour+seperator+minutes+seperator+seconds;
    }else{
        var currentdate = year + seperator1 + month + seperator1 + strDate;
    }

    return currentdate;
}